-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IC #5 Montana Pfeifer #12
base: main
Are you sure you want to change the base?
Conversation
expect(@vendor.check_stock(@item1)).to eq(0) | ||
end | ||
|
||
it 'stocks items in inventory' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are failing - we're getting an object back that looks like +#<Item:0x00007f9a182d3de0 @name="Peach", @price=0.75> => {:quantity=>30}
- I'd like to see something more like <Item:0x00007f7f2c2cfb48 @name="Tomato", @price=0.5> => 10
. What you did here works but doesnt quite follow the interaction pattern.
end | ||
|
||
def stock(item, quantity) | ||
@inventory[item][:quantity] += quantity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was expecting something a little more like this here @inventory[item] += quantity
|
||
def initialize(details) | ||
@name = details[:name] | ||
@price = details[:price].delete('$').to_f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Way to clean the string input, and convert it to the correct data type.
end | ||
|
||
def sorted_item_list | ||
@vendors.flat_map { |vendor| vendor.inventory.keys.map(&:name) }.uniq.sort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These one liners are nice !!
@vendors.flat_map { |vendor| vendor.inventory.keys.map(&:name) }.uniq.sort | ||
end | ||
|
||
def total_inventory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a simpler solution here! Might be worth asking ChatGPT :)
@market.add_vendor(@vendor3) | ||
|
||
expected = { | ||
@item1 => { quantity: 100, vendors: [@vendor1, @vendor3] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the interaction pattern, the items should looks like
pry(main)> vendor.inventory
#=> {#<Item:0x007f9c56740d48...> => 55, #<Item:0x007f9c565c0ce8...> => 12}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where the item object is the key, and the quantity is the value.
end | ||
|
||
it "calculates potential_revenue" do | ||
expect(@vendor1.potential_revenue).to eq(29.75) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that you are testing different vendors (scenarios) and testing how the outputs differ.
finished up to end of iteration 3